import { Component, OnInit, Input, ElementRef } from '@angular/core';
import { Zone } from '../../services/zone.service';

@Component({
	selector: 'm-tree-item',
	templateUrl: './tree-item.component.html',
	styleUrls: ['./tree-item.component.scss'],
})
export class TreeItemComponent implements OnInit {
	constructor(private el: ElementRef<HTMLDivElement>) {}
	closed = false;
	@Input() value: Zone[];
	ngOnInit() {}

	open() {
		this.closed = false;
		this.el.nativeElement.style.height = 'auto';
	}
	close() {
		this.closed = true;
		this.el.nativeElement.style.height = '0';
	}
	click(children: TreeItemComponent) {
		children.closed ? children.open() : children.close();
	}
}
